package com.imooc.ad;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * 广告检索系统启动类
 */
//引入 Feign, 可以以声明的方式调用微服务
@EnableFeignClients
@EnableEurekaClient
//引入断路器
@EnableHystrix
@EnableCircuitBreaker
//微服务发现
@EnableDiscoveryClient
//Hystrix监控
@EnableHystrixDashboard
@SpringBootApplication
public class SearchApplication {

    public static void main(String[] args) {

        SpringApplication.run(SearchApplication.class, args);
    }

    //通过Ribbon调用广告投放系统，需要定义一个rest客户端
    @Bean
    @LoadBalanced//负载均衡实现轮询
    RestTemplate restTemplate() {

        return new RestTemplate();
    }
}
